<style>
    .indexa{
        color: #c00;
    }
    .indexa:hover{
        color: #f60;
    }
    .NewDD .dd_info span a{text-decoration: none;}
</style>
<div class="center">
	<div class="home">
    	<div class="home_left">
            <?php echo $this->partial('member/menu.phtml',array('uCount' => $this->uCount,'menuId'=>$this->menuId,'user'=>$this->user,'account'=>$this->account)); ?>
        </div>
        <div class="home_right">
            <script type="text/javascript">
                $(function(){
                   $(".all").click(function(){
                       if($(this).attr('checked'))
                           $('input:checkbox').not(this).attr('checked', 'true');
                       else
                           $('input:checkbox').not(this).removeAttr('checked');
                   }); 
                   $('.Pageform a').click(function(){
                       $('#start').val($(this).attr('href').substr(7));
                       $(this).parents('form').submit();
                   });
                   $('.Search_left li').hover(function(){
                       $('.Dropdown_list',this).show();
                   }, function(){
                       $('.Dropdown_list',this).hide();
                   });
                   $('.Search_left .Dropdown_list a').click(function(){
                       $('a.Dropdownlist',$(this).parents('.Dropdown_list').prev()).html($(this).text());
                       $(this).parents('.Dropdown_list').hide();
                       return false;
                   });
                   $('._time a').click(function(){
                       $('#time').val($(this).attr('href').substr(1));
                       $('form').submit();
                   });
                   $('._status a').click(function(){
                       $('#status').val($(this).attr('href').substr(1));
                       $('form').submit();
                   });
                   $('.viewship').boxy({title: "物流跟踪", closeable: true}).click(function(){
                       var shipInfo =$(this).attr('href');
                       $(shipInfo).text('物流信息加载中,请稍候...');
                       $.post('/member/getingexpress', {type:3,id:$(this).attr('data')}, function(data){
                           $(shipInfo).html(data.content);
                       }, 'json').fail(function(){$(shipInfo).html('出错了!')});
                   });
                });
            </script>
			<div class="daigou_top">
            	<h1>我的代购订单</h1>
                
            </div>
            
		
            <div class="baobeilist">
            	<div class="list_top">
                    <table>
                        <tr>
                            <th class="b1">宝贝信息</th>
                            <th class="b2">单价</th>
                            <th class="b3">数量</th>
                            
                            <th class="b4">实付款(元)</th>
                            <th class="b5">交易状态</th>
                        </tr>
                    </table>
                </div>
                <div class="list_cz">
                    <table>
                    	<tbody><tr>
                        	<td class="cz_zuo"><input name="" type="checkbox" value=""></td>
                        	<td class="cz_zh">
                            	<a href="#" class="merger">合并付款</a>
                            </td>
                        	<td class="cz_you">
                                <div class="guolv">
                                    <ul>
                                        <li class="time">
                                            <div class="rmbxl">
                                                <?php if($this->stime=="-3") { ?>
                                                    <a href="javascript:void(0);"><span>最近三个月</span></a>
                                                <?php }else if($this->stime=="-6") { ?>
                                                    <a href="javascript:void(0);"><span>最近半年</span></a>
                                                <?php } else if($this->stime=="-12") { ?>
                                                    <a href="javascript:void(0);"><span>最近一年</span></a>
                                                <?php } else if($this->stime=="-36") { ?>
                                                    <a href="javascript:void(0);"><span>一年以前</span></a>
                                                <?php } ?>
                                            </div>
                                            <div class="xiala" id="time" style="display:none;">
                                                <dl style="margin:0;">
                                                    <dd><a href="?stime=-3&etime=1">最近三个月</a></dd>
                                                    <dd><a href="?stime=-6&etime=1">最近半年</a></dd>
                                                    <dd><a href="?stime=-12&etime=1">最近一年</a></dd>
                                                    <dd><a href="?stime=-36&etime=-12">一年以前</a></dd>
                                                </dl>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                            </td>
                        </tr>
                    </tbody>
                    </table>
                </div>
                <div class="list_table" style="margin-top:10px;">
                    <?php if (count($this->orderList)==0) {?>
                	<div class="Nogoods">
                        <div class="no_pic">
                            没有购买宝贝
                        </div>
                        <div class="NOsm">
                            <h2>您还没有通过悠奇购买过宝贝！</h2>
                            <p>猜您接下来会：<a href="/purchase/agent">我要代购</a></p>
                        </div>
                    </div>
                    <?php } else {
                        foreach ($this->orderList as $order){
                    ?>
                	<table class="NewDD">
                    	<tr>
                        	<th colspan="6">
                                <? if($order->Status == Application_Model_Order::STATUS_PAYING){?>
                                <label><input name="name" checked="checked" class="order_chk" type="checkbox" value="<?= $order->Id ?>"></label>
                                <? } ?>
                        <div class="dd_info">
                            <?php if($order->problem == Application_Model_Order::Problem_Appear || $order->problem == Application_Model_Order::Problem_User || $order->problem == Application_Model_Order::Problem_Complete){ ?>
                            <div style='float:right;margin-right: 20px;'>
                                <a class="indexa" href="javascript:setProblem(<?php echo $order->Id;?>)" title="问题代购">
                                    <?php echo ($order->problem == Application_Model_Order::Problem_Appear || $order->problem == Application_Model_Order::Problem_User)?"问题代购点击查看详情":"代购问题已解决点击查看详情";?>
                                </a>
                            </div>
                            <?php } ?>
                            <span>&nbsp;订单编号：<a href="/member/orderdetail/id/<?= $order->Id ?>" class="indexa"><?= $order->getOrderNum() ?></a></span><span>时间：<?php echo $order->DateCreated ?></span> <?if($order->logisticsNo){ ?> <span>物流单号:[<?= $order->logisticsBy->Name ?>]<?= $order->logisticsNo ?> <a class="viewship" data="<?= $order->Id ?>" href="#shipInfo<?= $order->Id ?>">物流跟踪</a></span>
                            <div id="shipInfo<?= $order->Id ?>" style="display:none;width: 560px">
                                物流信息加载中,请稍候...
                            </div>
                            
                            <? } ?></div>
                            </th>
                        </tr>
                        <?php 
                        $count =0;
                        $ad = Application_Model_AdLink::getByCode('order');
                        foreach($order->Items as $item){ 
                            $count++;
                            ?>
                        <tr>
                        	<td class="l1">
                                <div class="sp_pic">
                                    <a href="<?= $item->Product->Url ?>" target="_blank"><img src="<?php echo $item->Image ?>" alt="<?php echo $item->ProductName ?>" /></a>
                                </div>
                                <div class="sp_info">
                                    <h1><a href="<?php echo $item->Product->Url ?>" target="_blank"><?php echo $item->ProductName ?></a></h1>                                   
                                    <? if($item->Product->PropertyAlias){ ?>
                                    <div class="zdy" style="overflow:hidden" title="<?= $item->Product->PropertyAlias ?>">
                                      <?= $item->Product->PropertyAlias ?>
                                      </div>      
                                    <? } ?>
                                    <div class="Remarks">
                                        <p>商品备注: <?php echo $item->Comment == NULL || $item->Comment == ''?'(无)':$item->Comment ?></p>
                                        <? if($item->Description){ ?>
                                        <p style="color:red"><?= $item->Description ?></p>
                                        <? } ?>
                                    </div>
                                </div>
                            </td>
                        	<td class="l2"><?php echo $item->Price ?><span style="color:red"><br /><?= $item->StatusText ?></span></td>
                        	<td class="l3"><?php echo $item->Quantity ?></td>
                            <?php if ($count==1){?>
                            <td class="l4" rowspan="<?php echo count($order->Items) ?>">￥<?php echo $order->Sum ?>
                                <div class="zdy"><span><?= $order->ShipFee>0?('(含运费'.number_format($order->ShipFee). '元)'):'免运费' ?></span></div></td>
                            
                        	<td class="l5" rowspan="<?php echo count($order->Items) ?>">
                                <?php 
switch ($order->Status){
    case Application_Model_Order::STATUS_PAYING:
        echo '<div class="fk"><a href="/Pay/paying?type=2&id='.$order->Id .'">'. $order->getStatusText(). '</a></div>';
        break;
    default :
        echo '<p class="lvse">'. $order->getStatusText().'</p>';
        break;
}
                                ?>
                                <? if($order->Status < Application_Model_Order::STATUS_CONFRIM){ ?>
                                <a style="clear:both;display:block" href="/member/ordercancel?order=<?= $order->Id ?>">取消</a> 
                                <? } ?>                                
                                <div style="padding-top:20px;" onmouseover="setShare('<?= $ad->getTitle($item->Product->Url) ?>', '<?= $ad->getAdUrl($this->user->id) ?>','<?= $ad->getContent('') ?>','<?php echo $item->Image ?>');"> 
                                <!--自定义第一个分享标题和链接-->
                                <!-- JiaThis Button BEGIN -->
                                <div class="jiathis_style">       
                                <a href="http://www.jiathis.com/share/?uid=1334580904971198" class="jiathis" target="_blank">
                                    <img src="http://v2.jiathis.com/code_mini/images/btn/v1/jiathis3.gif" border="0" />
                                </a>
                                </div>
                                <!-- JiaThis Button END -->
                                </div>
                            </td>
                            <?php }?>
                        </tr>
                           <?php }?>            
                    </table>
                    <?php } 
                    }?>
                </div>
                <div class="toolbar">
                	<div class="toolbar_left">
                        <label class="TAll"><input name="" type="checkbox" value="" />全选</label>
                        <a class="cz_fk" href="#" class="merger">合并付款</a>
                    </div>
                    <?php echo $this->partial('paging.phtml',array('pages'=>$this->orders,'pamas'=>"stime=$this->stime&etime=$this->etime")) ?>
                	</div>
            </div>
            <form method="get" class="mergerform" action="/pay/paying/type/2">
                <?= $this->formHidden('id') ?>
            </form>
        </div>
    </div>
</div>
<div id="ProblemOrder" class="tanchuang" style="display:none;">
    <div class="nui-msgbox">
        <div class="nui-msgbox-hd" id="wayProblem">问题代购</div>
        <a class="nui-msgbox-close" title="关闭" onclick="closeDiv()"><b></b></a>
    </div>
    <div class="wt_top">
    	<div class="wt_nav">
            <ul>
            	<li class="wt_on"><a href="javascript:void(0)" id="problem">问题详情</a></li>
            </ul>
        </div>
    </div>
    <div class="wt_center" style="height:300px;">
            
    </div>
    <div class="wt_caozuo">
        <textarea name="content" cols="" rows="" id="content"></textarea>
        <input type="hidden" id="orderProblemId" name="orderProblemId" value="" />
        <a class="wt_liuyan" href="javascript:void(0);"><span>留言</span></a>
    </div>
</div>
<div class="houtai_overlay" style="display:none;"></div>
<script type="text/javascript">
    $(function(){
        $('.merger').click(function(){
            var values =[];
            $('.order_chk:checked').each(function(index,item){
                values.push($(item).val());
            });
            if(values.length ==0){
                alert('请选择要付款的订单');
                return false;
            }
            var ids = values.join(',');
            $('#id').val(ids);
            $('.mergerform').submit();
            return false;
        });
        $('.guolv li').eq(0).hover(function(){
            $('.guolv .xiala').eq(0).show();
            $('a',this).addClass('xialaon');
        }, function(){
            $('.guolv .xiala').eq(0).hide();
            $('a',this).removeClass('xialaon');
        });

        $('.guolv li').eq(1).hover(function(){
            $('.guolv #time').show();
            $('a',this).addClass('xialaon');
        }, function(){
            $('.guolv #time').hide();
            $('a',this).removeClass('xialaon');
        });
        
    });
    
        function closeDiv()
        {
            $("#ProblemOrder").hide();
            $(".houtai_overlay").hide();
        }
        
        /**
        * 设置问题展示
        */
       function setProblem(orderId)
       {
           $.ajax({
               type: 'POST',
               url: '/member/problemshow/orderId/' + orderId,
               success: function(data) {
                   if (data.type == 1) {
                       var html = "";
                       $.each(data.arrProblem, function(key, val) {
                           html += '<div class="'+(val.issueetype==1?'wt_uuch':'wt_kehu')+'">';
                           html += '<h2>'+(val.issueetype==1?'悠奇客服':('回复人：<a href="/admini/manageuser/userdetail/id/'+val.userId+'" target="_blank">'+val.userName+'</a>'));
                           html += '<span>'+val.dateCreated+'</span></h2>';
                           html += '<p>'+val.content+'</p></div>';
                       });
                       $(".wt_caozuo").show();
                       if(data.status){
                            $(".wt_caozuo").hide();
                       }
                       $("#ProblemOrder .wt_center").html(html);
                       $("#orderProblemId").val(orderId);
                       $("#ProblemOrder").show();
                       $(".houtai_overlay").show();
                   } else {
                       alert("发生未知错误，请重新操作");
                   }
               }
           });
       }

       $(".wt_liuyan").click(function(){
           var orderProblemId = $("#orderProblemId").val();
           var content = $("#content").val();
           
           if($.trim(content) == ""){
                alert("回复内容不能为空！");
                return false;
           }
           $.post('/member/addorderpb/orderProblemId/'+orderProblemId,{'content':content},function(data){
               if(data ==1){
                       alert("设置成功！");
                       $(".problem"+orderProblemId).show();
                       $("#content").val("");
                       $("#orderProblemId").val("");
                       closeDiv();
                   }else if (data == 2){
                       alert("回复内容不能为空！");
                   } else {
                       alert("发生未知错误，请重新操作");
                   }
           });
       });
</script>
<!--单页面使用多分享按钮需要增加的分享参数代码-->                        
<script type="text/javascript">
                          function setShare(title, url,content,pic) {
                              jiathis_config.title = title;
                              jiathis_config.url = url;
                              if(content){
                                jiathis_config.summary = content;
                              }
                              if(pic){
                                jiathis_config.pic = pic;
                              }
                          }
                            var jiathis_config = {}
                          </script>   
<!--分享参数代码结束-->
<!--分享功能代码统一放到页尾-->
<script type="text/javascript" src="http://v1.jiathis.com/code/jia.js?uid=1334580904971198" charset="utf-8"></script>
<!--分享功能代码结束-->
